﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Microsoft.Phone.Tasks;

namespace Utility
{
    public partial class SMSPage : PhoneApplicationPage
    {
        private string displayName;
        private string phoneNumber;
        public SMSPage()
        {
            InitializeComponent();
            displayName = "Help Me Please!";
            phoneNumber = "911";
        }

        private void openPhoneNumberBtn_Click(object sender, RoutedEventArgs e)
        {
            PhoneNumberChooserTask phonenum = new PhoneNumberChooserTask();
            phonenum.Completed += phonenum_Completed;
            phonenum.Show();
        }

        void phonenum_Completed(object sender, PhoneNumberResult e)
        {
            if (e.TaskResult == TaskResult.OK) {
                this.phoneNumber = e.PhoneNumber;
                smsPhoneNumberTxt.Text = e.PhoneNumber;
            }
        }

        private void sendBtn_Click(object sender, RoutedEventArgs e)
        {
            SmsComposeTask sms = new SmsComposeTask();
            sms.To = this.phoneNumber;
            sms.Body = smsBodyTxt.Text;
            sms.Show();
        }

        private void resetBtn_Click(object sender, RoutedEventArgs e)
        {
            smsPhoneNumberTxt.Text = "";
            smsBodyTxt.Text = "";
        }
    }
}